home *** CD-ROM | disk | FTP | other *** search
- Path: mail2news.demon.co.uk!genesis.demon.co.uk
- From: Lawrence Kirby <fred@genesis.demon.co.uk>
- Newsgroups: comp.lang.c
- Subject: Re: timimng an event in milli seconds.
- Date: Thu, 29 Feb 96 14:18:08 GMT
- Organization: none
- Message-ID: <825603488snz@genesis.demon.co.uk>
- References: <Pine.SUN.3.91.960218173348.23890B-100000@aloha.cc.columbia.edu> <4gv7hdINNb8v@anvil.ugrad.cs.ubc.ca>
- Reply-To: fred@genesis.demon.co.uk
- X-NNTP-Posting-Host: genesis.demon.co.uk
- X-Newsreader: Demon Internet Simple News v1.27
- X-Mail2News-Path: genesis.demon.co.uk
-
- In article <4gv7hdINNb8v@anvil.ugrad.cs.ubc.ca>
- c2a192@ugrad.cs.ubc.ca "Kazimir Kylheku" writes:
-
- >> I am interested in _milli seconds_ can anybody help me? I am also
- >>intersted in doing the same on the unix workstations at the university .
-
- You can time things down to the granularity of the system clock which is
- usually around 1/100sec in Unix. However you can't do it using standard C
- functions.
-
- >There is a _standard_ function called clock(), you know... it gives a time in
- >clock ticks, which you can divide by the clock tick period, given by
- >CLOCKS_PER_SECOND. Don't forget to #include <time.h>.
-
- That's CLOCKS_PER_SEC.
- >
- >BTW, I think that this is normally measured in virtual process time, not real
- >time.
-
- Yes, which means that on a multitasking system it is no good if you want
- to measure real time.
-
- >I doubt that you can get a more accurate timer without referring to
- >something like gettimeofday(), which is a UNIX thing, not a standard function.
- >gettimeofday() gives you a struct timeval, which contains seconds and
- >milliseconds.
- >
- >I know that it is available on PC's, since the requestor side of a
- >communication protocol of mine was recently ported to Windows/Winsock, and this
- >code uses gettimeofday() to measure round-trip times.
-
- It tends to be supplied in socket libraries so was probably a part of
- Winsock rather than Windows.
-
- --
- -----------------------------------------
- Lawrence Kirby | fred@genesis.demon.co.uk
- Wilts, England | 70734.126@compuserve.com
- -----------------------------------------
-